<template>
    <div class="left-220">
        <div class="bg-wrap nobg">
            <div class="sidebar-box">
                <h4>推荐商品</h4>
                <ul class="side-img-list">
                
                    <li v-for="(item, i) in list" :key="item.id">
                        <div class="img-box">
                            <label>{{ i + 1 }}</label>
                            <img :src="item.img_url | img">
                        </div>
                        <div class="txt-box">
                            <router-link :to="{name: 'goodsDetail', params: {id: item.id}}">{{ item.title }}</router-link>
                            <span>{{ item.add_time | date }}</span>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        // 接收父传过来的list数据
        props: ['list'],

        // 局部过滤器
        filters: {
            img(imgurl){
              imgurl.split(':8899')
              var newurl=imgurl.split(8899)
             
              return newurl[0]+'8899/'+newurl[1]
          }  ,
            // 日期过滤器
            date(tplDate) {
                let date = new Date(tplDate);
                return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
            }
        },
        created () {
                console.log(this.list)
        }
    }
</script>

<style scoped>

</style>